1 using System;
2 using
System.Collections.Generic;
3 using
System.Linq;
4 using
System.Security.Principal;
5 using
System.Threading.Tasks;
6 using
System.Windows.Forms;
7 using
System.Xml;
8
9
10 namespace
SoftQuanLyNhaHang
11 {
12     
static class Program
13     {

14         
15         ///
<summary>
16         ///
The main entry point for the application.
17         ///
</summary>
18         
[STAThread]
19         
static void Main()
20         {
21             
22             Application.EnableVisualStyles();
23             Application.SetCompatibleTextRenderingDefault(
false);
24
25             CauHinhHeThong.KET_NOI_CSDL = SoftQuanLyNhaHang.Models.connection.IsKet_Noi_CSDL();
26
27             
if (CauHinhHeThong.KET_NOI_CSDL == false)
28             {
29                 
//docten sql
30                 
string startupPath = System.IO.Directory.GetCurrentDirectory().Replace("\\bin\\Release", "\\Resources").Replace("\\bin\\Debug", "\\Resources");
31
32                 XmlDocument xmlDoc =
new XmlDocument();
33                 xmlDoc.Load(startupPath +
"/ConnectCSDL.xml");
34                 XmlNodeList nodeList = xmlDoc.DocumentElement.SelectNodes(
"/ConnectionString");
35                 
string nameSv = string.Empty;
36
37                 
foreach (XmlNode node in nodeList)
38                 {
39                     nameSv = node.SelectSingleNode(
"NameSv").InnerText;
40                 }
41                 
42
43                 
if (!string.IsNullOrEmpty(nameSv))
44                 {
45                     
//start sql service
46                     System.Diagnostics.Process process;
47                     System.Diagnostics.ProcessStartInfo startInfo;
48
49                     process =
new System.Diagnostics.Process();
50                     startInfo =
new System.Diagnostics.ProcessStartInfo();
51
52                     startInfo.UseShellExecute =
true;
53                     startInfo.Verb =
"runas";
54                     startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
55                     startInfo.FileName =
"cmd.exe";
56                     startInfo.Arguments =
"/C net start " + nameSv;
57                     process.StartInfo = startInfo;
58
59                     process.Start();
60                     process.WaitForExit();
61                 }
62             }
63
64             Application.Run(
new Views.frmMain());
65             
66         }
67     }
68 }


Gõ tìm kiếm nhanh...